package com.itshare.video.config;

import com.itshare.video.common.config.interceptor.LoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 404页面
 * @Author lyr
 * @create 2020/10/24 10:33
 */
@Slf4j
@Configuration
public class BaseWebCfg implements WebMvcConfigurer {



    //
    // @Override
    // public void addInterceptors(InterceptorRegistry registry) {
    //
    //     registry
    //             .addInterceptor(new LoginInterceptor())
    //             .addPathPatterns("/api/**")
    //             .excludePathPatterns("/api/getToken","/api/login/**","/api/register/**")
    //             ;
    // }


    @Bean
    public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {

        return (factory -> {
            ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
            factory.addErrorPages(errorPage404);
        });
    }

}
